#include"state.h"
#include<stdlib.h>
#include<stdio.h>

int delCL(CirList *c, ElemType *e){
	CirLiNode *pre, *p;
	if(c->node == NULL)	return 0;
	*e = c->node->data;
	if(c->node->next == c->node){
		free(c->node);
		c->node = NULL;
		return 1;
	}
	pre = c->node->next;
	while(pre->next != c->node)
		pre = pre->next;
	pre->next = c->node->next;
	p = c->node;
	c->node = c->node->next;
	free(p);
	return 1;
}
int addCL(CirList *c, ElemType e){
	CirLiNode * newN;
	newN = (CirLiNode *)malloc(sizeof(CirLiNode));
	if(!newN) return 0;
	newN->data = e;
	if(c->node == NULL){
		c->node = newN;
		newN->next = newN;
		return 1;
	}
	newN->next = c->node->next;
	c->node->next = newN;
	c->node=newN;
	return 1;
}
int emptyCL(CirList c){
	if(c.node == NULL) return 1;
	else return 0;
}
void traverseCL(CirList c){
	CirLiNode *p;
	p = c.node;
	printf("%d:  %d\n", p->data.people, p->data.key);
	while(p->next != c.node){
		printf("%d:  %d\n",p->next->data.people, p->next->data.key);
		p = p->next;
	}
}